<script lang="ts" setup>
import { ref } from 'vue'
import {
	Check,
	Delete,
	Edit,
	Message,
	Search,
	Star,
} from '@element-plus/icons-vue'

const loading = ref(true)
const currentDate = new Date().toDateString()
</script>

<template>
	<div class="scroll-container element">
		<div class="sticky-element w-[1200px] h-[200px] mx-auto"></div>
		<!-- 其他内容 -->
		<el-affix :offset="36">
			<el-anchor :offset="70" direction="horizontal">
				<el-anchor-link href="#a"> 解决方案 </el-anchor-link>
				<el-anchor-link href="#b"> 产品服务 </el-anchor-link>
				<el-anchor-link href="#c"> 新闻中心 </el-anchor-link>
				<el-anchor-link href="#d"> 发展战略 </el-anchor-link>
			</el-anchor>
		</el-affix>
		<div class="aList">
			<div class="aItem" id="a">
				解决方案
				<el-watermark :content="['Element+', 'Element Plus']">
					<div style="height: 560px;">
						<div style="height: 100px;">
							<el-scrollbar height="100px">
								<div>
									<el-link href="https://element-plus.org" target="_blank">default</el-link>
									<el-link type="primary">primary</el-link>
									<el-link type="success">success</el-link>
									<el-link type="info">info</el-link>
									<el-link type="warning">warning</el-link>
									<el-link type="danger">danger</el-link>
								</div>
								<div>
									<el-text class="mx-1">Default</el-text>
									<el-text class="mx-1" type="primary">Primary</el-text>
									<el-text class="mx-1" type="success">Success</el-text>
									<el-text class="mx-1" type="info">Info</el-text>
									<el-text class="mx-1" type="warning">Warning</el-text>
									<el-text class="mx-1" type="danger">Danger</el-text>
								</div>
								<div class="button-example">
									<div class="button-row">
										<el-button>Default</el-button>
										<el-button type="primary">Primary</el-button>
										<el-button type="success">Success</el-button>
										<el-button type="info">Info</el-button>
										<el-button type="warning">Warning</el-button>
										<el-button type="danger">Danger</el-button>
									</div>

									<div class="button-row">
										<el-button plain>Plain</el-button>
										<el-button type="primary" plain>Primary</el-button>
										<el-button type="success" plain>Success</el-button>
										<el-button type="info" plain>Info</el-button>
										<el-button type="warning" plain>Warning</el-button>
										<el-button type="danger" plain>Danger</el-button>
									</div>

									<div class="button-row">
										<el-button round>Round</el-button>
										<el-button type="primary" round>Primary</el-button>
										<el-button type="success" round>Success</el-button>
										<el-button type="info" round>Info</el-button>
										<el-button type="warning" round>Warning</el-button>
										<el-button type="danger" round>Danger</el-button>
									</div>

									<div class="button-row">
										<el-button :icon="Search" circle />
										<el-button type="primary" :icon="Edit" circle />
										<el-button type="success" :icon="Check" circle />
										<el-button type="info" :icon="Message" circle />
										<el-button type="warning" :icon="Star" circle />
										<el-button type="danger" :icon="Delete" circle />
									</div>
								</div>
							</el-scrollbar>
						</div>
						<div class="mt-4" style="height: 200px; box-shadow: var(--el-border-color-light) 0px 0px 10px">
							<el-splitter>
								<el-splitter-panel size="30%">
									<div class="demo-panel">1</div>
								</el-splitter-panel>
								<el-splitter-panel :min="200">
									<div class="demo-panel">2</div>
								</el-splitter-panel>
							</el-splitter>
						</div>
						<div class="mt-4" style="height: 200px; box-shadow: var(--el-border-color-light) 0px 0px 10px">
							<el-splitter layout="vertical">
								<el-splitter-panel>
									<div class="demo-panel">1</div>
								</el-splitter-panel>
								<el-splitter-panel>
									<div class="demo-panel">2</div>
								</el-splitter-panel>
							</el-splitter>
						</div>
					</div>
				</el-watermark>
			</div>
			<el-divider />
			<div class="aItem" id="b">
				产品服务
				<el-space direction="vertical" alignment="flex-start">
					<div>
						<el-switch v-model="loading" />
					</div>
					<el-skeleton :rows="5" animated :loading="loading" :throttle="{ leading: 500, trailing: 500, initVal: true }">
						<template #template>
							<el-skeleton-item variant="image" style="width: 240px; height: 240px" />
							<div style="padding: 14px">
								<el-skeleton-item variant="h3" style="width: 50%" />
								<div style="
										display: flex;
										align-items: center;
										justify-items: space-between;
										margin-top: 16px;
										height: 16px;
									">
									<el-skeleton-item variant="text" style="margin-right: 16px" />
									<el-skeleton-item variant="text" style="width: 30%" />
								</div>
							</div>
						</template>
						<template #default>
							<el-card :body-style="{ padding: '0px', marginBottom: '1px' }">
								<img src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png"
									class="image" />
								<div style="padding: 14px">
									<span>Delicious hamburger</span>
									<div class="bottom card-header">
										<div class="time">{{ currentDate }}</div>
										<el-button text class="button">Operation button</el-button>
									</div>
								</div>
							</el-card>
						</template>
					</el-skeleton>
				</el-space>
			</div>
			<el-divider />
			<div class="aItem" id="c"> 新闻中心
				<el-empty class="emptyBox" :image-size="200" />
				<el-empty class="emptyBox" :image-size="200" />
				<el-empty class="emptyBox" :image-size="200" />
				<el-empty class="emptyBox" :image-size="200" />
			</div>
			<el-divider />
			<div class="aItem" id="d"> 发展战略 </div>
		</div>
	</div>
	<el-backtop />
	<!-- <el-backtop :right="100" :bottom="100" /> -->
	<footer></footer>
</template>

<style lang="scss" scoped>
.scroll-container {
	min-height: 4000px;
}

.aList {
	.aItem {
		display: block;
		min-height: 500px;
		padding: 16px;
		margin: 10px 0;
	}
}

@keyframes slideIn {
	0% {
		transform: translateX(100%);
		opacity: 0;
	}

	100% {
		transform: translateX(0%);
		opacity: 1;
	}
}

@keyframes progress-expand {
	from {
		width: 0%
	}

	to {
		width: 100%
	}
}

.emptyBox {
	animation: slideIn;
	animation-timeline: view(); // 看到元素时候动画开始执行
	animation-range: 0% 50%; // 看到元素时候滚动到50%时候动画完成
}

footer {
	height: 2px;
	width: 100%;
	background: rgba(254, 178, 16, 1);
	left: 0;
	bottom: 0;
	position: fixed;
	// animation: progress-expand 2s linear infinite alternate;
	animation: progress-expand linear;
	// 将动画时间线设置为与页面滚动关联
	animation-timeline: scroll();
}

:deep(.el-anchor.el-anchor--horizontal) {
	width: 520px;
	margin: 0 auto;
	border-radius: 10px;
	overflow: hidden;
	padding: 0 40px;

	.el-anchor__marker {
		height: 2px;
	}

	.el-anchor__list {
		.el-anchor__item {
			padding-left: 27px;

			.el-anchor__link {
				font-size: 16px;
			}

			.el-anchor__link.is-active {
				font-weight: normal;
			}
		}
	}
}

.button-example {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.button-row {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	align-items: center;
}

.button-row>* {
	margin: 0;
}

.demo-panel {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
}
</style>